import { Loading } from "ionic-angular/components/loading/loading";
import { LoadingController } from "ionic-angular/components/loading/loading-controller";
import { ToastController } from "ionic-angular/components/toast/toast-controller";

/**
 * UI层所有公用方法的抽象类
 * 
 * @export
 * @abstract
 * @class BaseUI
 */
export abstract class BaseUI {
    constructor() {
        
    }
    /**
     * 通用的loading组件
     * 
     * @protected
     * @param {LoadingController} loadingCtrl 
     * @param {string} message 
     * @returns {Loading} 
     * @memberof BaseUI
     */
    protected showLoading(loadingCtrl: LoadingController,
                           message: string ): Loading {
       let loader = loadingCtrl.create({
           content: message,
           dismissOnPageChange: true    //页面变化关闭loading
       })
       loader.present()
       return loader
    }

    protected showToast(toastCtrl: ToastController, message: string) {
        let toast = toastCtrl.create({
            message: message,
            duration: 3000,
            position: 'bottom'
        })
        toast.present()
    }
}